package cn.singno.bob.web.base;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import cn.singno.bob.web.editor.BooleanEditor;
import cn.singno.bob.web.editor.ByteEditor;
import cn.singno.bob.web.editor.CharacterEditor;
import cn.singno.bob.web.editor.DoubleEditor;
import cn.singno.bob.web.editor.FloatEditor;
import cn.singno.bob.web.editor.IntegerEditor;
import cn.singno.bob.web.editor.LongEditor;
import cn.singno.bob.web.editor.ShortEditor;
import cn.singno.bob.web.editor.StringEditor;



/**
 * <p>名称：BaseController.java</p>
 * <p>描述：</p>
 * <pre>
 *    
 * </pre>
 * @author 鲍建明
 * @date 2014年11月3日 下午8:00:27
 * @version 1.0.0
 */
public abstract class BaseController/*<T, ID extends Serializable>*/ {

	
	//private BaseService<T, ID> baseService;
	
	/**
	 * 
	 * <p>描述：通用删除方法</p>
	 * <pre>
	 *    
	 * </pre>
	 * @param deleteBean
	 * @return
	 *//*
	@ResponseBody
	@RequestMapping(value = { "/deleteAll" }, method = {RequestMethod.POST })
	public JsonMessage deleteAll(List<T> deleteBean){
		System.out.println(JSON.toJSONString(deleteBean));
		baseService.delete(deleteBean);
		
		return JsonMessageUtils.getJsonMessage(CommonEmun.SUCCESS);
	}*/
	
	
	@InitBinder
	protected void initBinder(HttpServletRequest request,
			ServletRequestDataBinder binder) throws Exception {
	     binder.registerCustomEditor(Boolean.class, new BooleanEditor());
	     binder.registerCustomEditor(String.class, new StringEditor());
	     binder.registerCustomEditor(Byte.class, new ByteEditor());
	     binder.registerCustomEditor(Character.class, new CharacterEditor());
	     binder.registerCustomEditor(Double.class, new DoubleEditor());
	     binder.registerCustomEditor(Float.class, new FloatEditor());
	     binder.registerCustomEditor(Integer.class, new IntegerEditor());
	     binder.registerCustomEditor(Long.class, new LongEditor());
	     binder.registerCustomEditor(Short.class, new ShortEditor());
	     
	}
	
/*	
 * 统一错误移动到拦截器中去了
 * 
 * @ExceptionHandler(Exception.class)
	public ModelAndView exception(Exception e, HttpServletRequest request) {
		e.printStackTrace();
		
		request.setAttribute("exception", e);
		
		if (ServerInfo.isAjax(request) || request.getParameter("ajax") != null) {
			return ajaxDoneError(e.getMessage());
		}
		
		ModelAndView mav = new ModelAndView("error");
		mav.addObject("statusCode", 300);
		mav.addObject("message", e.getMessage());
		
		return mav;
	}*/
	
	
	
	

	
}
